/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 25228
 * Date: 2024-07-27
 * Time: 15:57
 */
class Solution2 {
    public int removeDuplicates(int[] nums) {
        int k=1;
        if(nums.length==0){
            return 0;
        }
        for (int i = 1; i < nums.length; i++) {
            if (nums[i] != nums[i - 1]) {
                nums[k] = nums[i];
                k++;
            }
        }
        return k;
    }
}